package org.example.entity;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

public class Employee {
    private int empId;
    private String empName;
    private String job;
    private int mgrId;
    private Date hireDate;
    private double sal;
    private double comm;
    private int dept_id;

    public Employee() {
    }

    public Employee(int empId, String empName, String job, int mgrId,
                    Date hireDate, double sal, double comm, int dept_id) {
        this.empId = empId;
        this.empName = empName;
        this.job = job;
        this.mgrId = mgrId;
        this.hireDate = hireDate;
        this.sal = sal;
        this.comm = comm;
        this.dept_id = dept_id;
    }

    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    public String getEmpName() {
        return empName;
    }
    public void setEmpName(String empName) {
        this.empName = empName;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public int getMgrId() {
        return mgrId;
    }

    public void setMgrId(int mgrId) {
        this.mgrId = mgrId;
    }

    public Date getHireDate() {
        return hireDate;
    }

    public void setHireDate(Date hireDate) {
        this.hireDate = hireDate;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        if(sal <= 0) {
            return;
        }
        this.sal = sal;
    }

    public double getComm() {
        return comm;
    }

    public void setComm(double comm) {
        if(comm <= 0) {
            return;
        }
        this.comm = comm;
    }

    public int getDept_id() {
        return dept_id;
    }

    public void setDept_id(int dept_id) {
        this.dept_id = dept_id;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "empId=" + empId +
                ", empName='" + empName + '\'' +
                ", job='" + job + '\'' +
                ", mgrId=" + mgrId +
                ", hireDate=" + hireDate +
                ", sal=" + sal +
                ", comm=" + comm +
                ", dept_id=" + dept_id +
                '}';
    }

    public static Employee map(ResultSet rs) throws SQLException {
        return new Employee(
                rs.getInt("emp_id"),
                rs.getString("emp_name"),
                rs.getString("job"),
                rs.getInt("mgr_id"),
                rs.getDate("hire_date"),
                rs.getDouble("sal"),
                rs.getDouble("comm"),
                rs.getInt("dept_id")
        );
    }

    public void setDeptName(String deptName) {

    }

    public void setDeptLoc(String deptLoc) {
    }

    public Object getDeptName() {
        return 0;
    }

    public Object getDeptLoc() {
        return 0;
    }
}
